<template>
	<view class="cover bcf" style="overflow-y: auto;z-index: 999;height: 100vh;background-color: #EEE;" v-show="showStatus">
		<scroll ref="mescrollRef" @init="mescrollInit" :down="downOption"  @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
			<cu-custom bgColor="bg-gradual-blue">
				<view slot="content">选择物资</view>
				<view class="padl2" slot="right" @click="showStatus = false">
					<view class="cu-btn round"><text class="cuIcon cuIcon-close"></text></view>
				</view>
			</cu-custom>
			<view class="bcf padlr3 padtb2 bdtso">
				<search class="fs8 tac" placeholder="名称\编码\型号"  v-model="search" @search="doSearch()"></search>
			</view>
			<view class="flrc bcf pad3 bdtso bdbso fs8">
				<view class="flex1"><scondition @input="reload()" model="StoreUnit" 
				v-model="where.eq.unit" label="计量单位"></scondition></view>
				<view class="flex1"><scondition @input="reload()" model="StoreCategory" 
				v-model="where.eq.category" label="物料分类"></scondition></view>
				<view class="flex1"><scondition @input="reload()" model="MachineGroup" v-model="where.eq.groups" label="设备标记"></scondition></view>
			</view>
			<view class="padlr3">
				<view class="bcf pos-r mart3 pad2 round2 shadow" @tap="selectIt(item)" v-for="item in data" :key="item.id">
					<store :item="item"></store>
					<ripple></ripple>
				</view>
			</view>
			<loading :loading="myIsLoading"></loading>
		</scroll>
	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import List from '../../assets/js/list.js'
	let list = new List()
	
	import store from '../../templete/store/store_item.vue'
	
	export default {
		mixins:[MescrollMixin],
		components:{store},
		props:{
			value:'',
			show:false
		},
		data() {
			return {
				where:{
					eq:{
						status:'',
						category:'',
						groups:'',
					}
				},
				search:"",
				data:[],
				showStatus:false
			}
		},
		methods: {
			reload(){
				this.showLoading()
				list.setData({_order:{id:"DESC"},_where:this.where,_search:this.search}).reload()
			},
			doSearch(){
				this.showLoading()
				list.setData({_order:{id:"DESC"},_where:this.where,_search:this.search}).reload()
			},
			selectIt(item){
				// this.show = false
				let id = item.id
				this.showStatus = false
				this.$emit('input','/api_/store_items/'+ id)
				this.$emit('onSelect',{
					iri:'/api_/store_items/'+ id,
					id:id,
					en:item
				})
			}
		},
		mounted() {
			list.initMescroll(this).setUrl('/api/storeItems').setData({_order:{id:"DESC"},_where:this.where,_search:this.search}).setCbFunc(res=>{
				this.data = res
				this.clearLoading()
			}).reload()
			
		},
		onLoad() {
			
		},
		watch:{
			show(val){
				this.log(val)
				this.showStatus = this.$com.isbool(val)
			}
		}
	}
</script>

<style>

</style>
